﻿<UserControl x:Class="DaxStudio.UI.Views.ucSpinner"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="20" d:DesignWidth="20">
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
        <SolidColorBrush x:Key="SpinnerColorBrush" Color="Black"></SolidColorBrush>
        <Storyboard x:Key="Rotation">

            <DoubleAnimation Storyboard.TargetName="rotateTransform"
                       Storyboard.TargetProperty="Angle"
                       From="0" To="360" Duration="00:00:01"
                       RepeatBehavior="Forever"/>
        </Storyboard>

        <ControlTemplate x:Key="Spinner">
            <Grid Name="LayoutRoot" RenderTransformOrigin="0.5,0.5">
                <Grid.RenderTransform>
                    <TransformGroup>
                        <RotateTransform x:Name="rotateTransform"/>
                    </TransformGroup>
                </Grid.RenderTransform>
                <Ellipse Fill="{TemplateBinding Foreground }">
                    <!--<Ellipse Fill="{DynamicResource SpinnerColorBrush}">-->
                    
                    <Ellipse.OpacityMask>
                        <ImageBrush ImageSource="../Images/SpinnerMask.png" Stretch="None"/>
                    </Ellipse.OpacityMask>
                </Ellipse>
                <Grid.OpacityMask>
                    <RadialGradientBrush>
                        <GradientStop Color="Black" Offset="0.96"/>
                        <GradientStop Color="Transparent" Offset="0.959"/>
                    </RadialGradientBrush>
                </Grid.OpacityMask>
            </Grid>
        </ControlTemplate>

    </UserControl.Resources>
    <Grid>
        <Grid Background="Transparent">
            <!--    <ContentControl x:Name="Spinner"></ContentControl> -->
            <Grid Name="LayoutRoot" RenderTransformOrigin="0.5,0.5" Width="14" Height="14" Visibility="{Binding Working, Converter={StaticResource BoolToVisibilityConverter}}">
                <Grid.RenderTransform>
                    <TransformGroup>
                        <RotateTransform x:Name="rotateTransform"/>
                    </TransformGroup>
                </Grid.RenderTransform>
                <!--<Ellipse Fill="{DynamicResource SpinnerColorBrush}">-->
                <Ellipse Fill="White">
                    <Ellipse.OpacityMask>
                        <ImageBrush ImageSource="../Images/SpinnerMask.png" Stretch="None"/>
                    </Ellipse.OpacityMask>
                </Ellipse>
                <Grid.OpacityMask>
                    <RadialGradientBrush>
                        <GradientStop Color="Black" Offset="0.96"/>
                        <GradientStop Color="Transparent" Offset="0.7"/>
                    </RadialGradientBrush>
                </Grid.OpacityMask>
                <Grid.Triggers>
                    <EventTrigger RoutedEvent="Window.Loaded">
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Storyboard.TargetName="rotateTransform"
                                            Storyboard.TargetProperty="Angle"
                                            From="0" To="360" Duration="00:00:01"
                                            RepeatBehavior="Forever"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </Grid.Triggers>
            </Grid>
        </Grid>
    </Grid>
</UserControl>
